<html>
   <head>
      <link rel="stylesheet" type="text/css" href="style.css" />
   </head>
   <body onload="">
<h2 class="comptitle">NED File <i>src/overlay/pastry/Pastry.ned</i></h2>
<table class="typetable">
   <tr>
      <th>Name</th>
      <th>Description</th>
   </tr>
<tr>
   <td>
      <a href="oversim.overlay.pastry.BasePastry.html">BasePastry</a>
      <i> (simple&nbsp;module)</i>
   </td>
   <td>
<i>(no description)</i>
   </td>
</tr>
<tr>
   <td>
      <a href="oversim.overlay.pastry.Pastry.html">Pastry</a>
      <i> (simple&nbsp;module)</i>
   </td>
   <td>

<p>The main module of the <a href="oversim.overlay.pastry.Pastry.html">Pastry</a> implementation</p>
   </td>
</tr>
<tr>
   <td>
      <a href="oversim.overlay.pastry.PastryRoutingTable.html">PastryRoutingTable</a>
      <i> (simple&nbsp;module)</i>
   </td>
   <td>

<p>This module contains the routing table of the <a href="oversim.overlay.pastry.Pastry.html">Pastry</a> implementation.</p>
   </td>
</tr>
<tr>
   <td>
      <a href="oversim.overlay.pastry.PastryLeafSet.html">PastryLeafSet</a>
      <i> (simple&nbsp;module)</i>
   </td>
   <td>

<p>This module contains the leaf set of the <a href="oversim.overlay.pastry.Pastry.html">Pastry</a> implementation.</p>
   </td>
</tr>
<tr>
   <td>
      <a href="oversim.overlay.pastry.PastryNeighborhoodSet.html">PastryNeighborhoodSet</a>
      <i> (simple&nbsp;module)</i>
   </td>
   <td>

<p>This module contains the neighborhood set of the <a href="oversim.overlay.pastry.Pastry.html">Pastry</a> implementation.</p>
   </td>
</tr>
<tr>
   <td>
      <a href="oversim.overlay.pastry.PastryModules.html">PastryModules</a>
      <i> (compound&nbsp;module)</i>
   </td>
   <td>

<p>Implementation of the <a href="oversim.overlay.pastry.Pastry.html">Pastry</a> KBR overlay as described in
"<a href="oversim.overlay.pastry.Pastry.html">Pastry</a>: Scalable, Decentralized Object Location, and 
Routing for Large-Scale Peer-to-Peer Systems" 
by Antony Rowstron and Peter Druschel, published in 
Lecture Notes in Computer Science, volume 2218.</p>
   </td>
</tr>
</table>
<h3 class="subtitle">Source code:</h3>
<pre class="src"><span style="color: #808080; font-style: italic; ">//
// Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH)
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//
</span><span style="color: #000000; ">
</span><span style="color: #800000; font-weight: bold; ">package</span><span style="color: #000000; "> </span><span style="color: #000000; ">oversim</span><span style="color: #000000; ">.</span><span style="color: #000000; ">overlay</span><span style="color: #000000; ">.</span><span style="color: #000000; ">pastry</span><span style="color: #000000; ">;

</span><span style="color: #800000; font-weight: bold; ">import</span><span style="color: #000000; "> </span><span style="color: #000000; ">oversim</span><span style="color: #000000; ">.</span><span style="color: #000000; ">common</span><span style="color: #000000; ">.</span><span style="color: #000000; ">BaseOverlay</span><span style="color: #000000; ">;
</span><span style="color: #800000; font-weight: bold; ">import</span><span style="color: #000000; "> </span><span style="color: #000000; ">oversim</span><span style="color: #000000; ">.</span><span style="color: #000000; ">common</span><span style="color: #000000; ">.</span><span style="color: #000000; ">IOverlay</span><span style="color: #000000; ">;


</span><span style="color: #800000; font-weight: bold; ">simple</span><span style="color: #000000; "> </span><span style="color: #000000; ">BasePastry</span><span style="color: #000000; "> </span><span style="color: #800000; font-weight: bold; ">extends</span><span style="color: #000000; "> </span><span style="color: #000000; ">BaseOverlay</span><span style="color: #000000; ">
{
    </span><span style="color: #800000; font-weight: bold; ">parameters</span><span style="color: #000000; ">:

        </span><span style="color: #000080; font-weight: bold; ">bool</span><span style="color: #000000; "> </span><span style="color: #000000; ">enableNewLeafs</span><span style="color: #000000; ">;          </span><span style="color: #808080; font-style: italic; ">// enable Pastry API call newLeafs()
</span><span style="color: #000000; ">        </span><span style="color: #000080; font-weight: bold; ">bool</span><span style="color: #000000; "> </span><span style="color: #000000; ">optimizeLookup</span><span style="color: #000000; ">;          </span><span style="color: #808080; font-style: italic; ">// whether to search the closest node
</span><span style="color: #000000; ">                                      </span><span style="color: #808080; font-style: italic; ">// in findCloserNode() calls
</span><span style="color: #000000; ">        </span><span style="color: #000080; font-weight: bold; ">int</span><span style="color: #000000; "> </span><span style="color: #000000; ">bitsPerDigit</span><span style="color: #000000; ">;             </span><span style="color: #808080; font-style: italic; ">// bits per Pastry digit
</span><span style="color: #000000; ">        </span><span style="color: #000080; font-weight: bold; ">int</span><span style="color: #000000; "> </span><span style="color: #000000; ">numberOfLeaves</span><span style="color: #000000; ">;           </span><span style="color: #808080; font-style: italic; ">// number of entries in leaf set
</span><span style="color: #000000; ">        </span><span style="color: #000080; font-weight: bold; ">int</span><span style="color: #000000; "> </span><span style="color: #000000; ">numberOfNeighbors</span><span style="color: #000000; ">;        </span><span style="color: #808080; font-style: italic; ">// number of entries in neighborhoot set
</span><span style="color: #000000; ">        </span><span style="color: #000080; font-weight: bold; ">double</span><span style="color: #000000; "> </span><span style="color: #000000; ">joinTimeout</span><span style="color: #000000; "> </span><span style="color: #000000; font-weight: bold; ">@unit</span><span style="color: #000000; ">(</span><span style="color: #000000; ">s</span><span style="color: #000000; ">);  </span><span style="color: #808080; font-style: italic; ">// seconds to wait for STATE message
</span><span style="color: #000000; ">                                      </span><span style="color: #808080; font-style: italic; ">// from closest node
</span><span style="color: #000000; ">        </span><span style="color: #000080; font-weight: bold; ">double</span><span style="color: #000000; "> </span><span style="color: #000000; ">repairTimeout</span><span style="color: #000000; "> </span><span style="color: #000000; font-weight: bold; ">@unit</span><span style="color: #000000; ">(</span><span style="color: #000000; ">s</span><span style="color: #000000; ">);</span><span style="color: #808080; font-style: italic; ">// how long to wait for repair messages
</span><span style="color: #000000; ">        </span><span style="color: #000080; font-weight: bold; ">bool</span><span style="color: #000000; "> </span><span style="color: #000000; ">useRegularNextHop</span><span style="color: #000000; ">;
        </span><span style="color: #000080; font-weight: bold; ">bool</span><span style="color: #000000; "> </span><span style="color: #000000; ">alwaysSendUpdate</span><span style="color: #000000; ">;
                                      </span><span style="color: #808080; font-style: italic; ">// tables delayed (should be very small)
</span><span style="color: #000000; ">        </span><span style="color: #000080; font-weight: bold; ">double</span><span style="color: #000000; "> </span><span style="color: #000000; ">readyWait</span><span style="color: #000000; "> </span><span style="color: #000000; font-weight: bold; ">@unit</span><span style="color: #000000; ">(</span><span style="color: #000000; ">s</span><span style="color: #000000; ">);    </span><span style="color: #808080; font-style: italic; ">// seconds to wait for missing state
</span><span style="color: #000000; ">                                      </span><span style="color: #808080; font-style: italic; ">// messages in JOIN phase
</span><span style="color: #000000; ">        </span><span style="color: #000080; font-weight: bold; ">bool</span><span style="color: #000000; "> </span><span style="color: #000000; ">proximityNeighborSelection</span><span style="color: #000000; ">; </span><span style="color: #808080; font-style: italic; ">// enable PNS ?
</span><span style="color: #000000; ">}
</span><span style="color: #808080; font-style: italic; ">//
// The main module of the Pastry implementation
//
// </span><span style="color: #000080; ">@author</span><span style="color: #808080; font-style: italic; "> Felix Palmen
//
</span><span style="color: #800000; font-weight: bold; ">simple</span><span style="color: #000000; "> </span><span style="color: #000000; ">Pastry</span><span style="color: #000000; "> </span><span style="color: #800000; font-weight: bold; ">extends</span><span style="color: #000000; "> </span><span style="color: #000000; ">BasePastry</span><span style="color: #000000; ">
{
    </span><span style="color: #800000; font-weight: bold; ">parameters</span><span style="color: #000000; ">:
        </span><span style="color: #000000; font-weight: bold; ">@class</span><span style="color: #000000; ">(</span><span style="color: #000000; ">Pastry</span><span style="color: #000000; ">);

        </span><span style="color: #000080; font-weight: bold; ">bool</span><span style="color: #000000; "> </span><span style="color: #000000; ">partialJoinPath</span><span style="color: #000000; ">;             </span><span style="color: #808080; font-style: italic; ">// allow join even with missing state
</span><span style="color: #000000; ">                                          </span><span style="color: #808080; font-style: italic; ">// message along the routing path
</span><span style="color: #000000; ">        </span><span style="color: #000080; font-weight: bold; ">double</span><span style="color: #000000; "> </span><span style="color: #000000; ">secondStageWait</span><span style="color: #000000; "> </span><span style="color: #000000; font-weight: bold; ">@unit</span><span style="color: #000000; ">(</span><span style="color: #000000; ">s</span><span style="color: #000000; ">);  </span><span style="color: #808080; font-style: italic; ">// how long to wait before starting
</span><span style="color: #000000; ">                                          </span><span style="color: #808080; font-style: italic; ">// second stage of init phase
</span><span style="color: #000000; ">        </span><span style="color: #000080; font-weight: bold; ">bool</span><span style="color: #000000; "> </span><span style="color: #000000; ">pingBeforeSecondStage</span><span style="color: #000000; ">;
        </span><span style="color: #808080; font-style: italic; ">// join at nearest node, otherwise use bootstrapnode
</span><span style="color: #000000; ">        </span><span style="color: #000080; font-weight: bold; ">bool</span><span style="color: #000000; "> </span><span style="color: #000000; ">useDiscovery</span><span style="color: #000000; ">;
        </span><span style="color: #808080; font-style: italic; ">// use smaller join state msgs (as described in the 2nd Pastry paper)
</span><span style="color: #000000; ">        </span><span style="color: #000080; font-weight: bold; ">bool</span><span style="color: #000000; "> </span><span style="color: #000000; ">minimalJoinState</span><span style="color: #000000; ">;
        </span><span style="color: #808080; font-style: italic; ">// use state messages for leafset repair, otherwise use leafset messages
</span><span style="color: #000000; ">        </span><span style="color: #000080; font-weight: bold; ">bool</span><span style="color: #000000; "> </span><span style="color: #000000; ">sendStateAtLeafsetRepair</span><span style="color: #000000; ">;
        </span><span style="color: #808080; font-style: italic; ">// how long to wait for leafset pings in discovery stage
</span><span style="color: #000000; ">        </span><span style="color: #000080; font-weight: bold; ">double</span><span style="color: #000000; "> </span><span style="color: #000000; ">discoveryTimeoutAmount</span><span style="color: #000000; "> </span><span style="color: #000000; font-weight: bold; ">@unit</span><span style="color: #000000; ">(</span><span style="color: #000000; ">s</span><span style="color: #000000; ">);
        </span><span style="color: #808080; font-style: italic; ">// interval for periodic routing table maintenance
</span><span style="color: #000000; ">        </span><span style="color: #000080; font-weight: bold; ">double</span><span style="color: #000000; "> </span><span style="color: #000000; ">routingTableMaintenanceInterval</span><span style="color: #000000; "> </span><span style="color: #000000; font-weight: bold; ">@unit</span><span style="color: #000000; ">(</span><span style="color: #000000; ">s</span><span style="color: #000000; ">);
        </span><span style="color: #808080; font-style: italic; ">// pastry configuration according to the original paper
</span><span style="color: #000000; ">        </span><span style="color: #000080; font-weight: bold; ">bool</span><span style="color: #000000; "> </span><span style="color: #000000; ">overrideOldPastry</span><span style="color: #000000; ">;
        </span><span style="color: #000080; font-weight: bold; ">bool</span><span style="color: #000000; "> </span><span style="color: #000000; ">overrideNewPastry</span><span style="color: #000000; ">;            </span><span style="color: #808080; font-style: italic; ">// optimized pastry configuration
</span><span style="color: #000000; ">        </span><span style="color: #000000; font-weight: bold; ">@display</span><span style="color: #000000; ">(</span><span style="color: #008000; ">&quot;i=block/circle&quot;</span><span style="color: #000000; ">);
}

</span><span style="color: #808080; font-style: italic; ">//
// This module contains the routing table of the Pastry implementation.
//
// </span><span style="color: #000080; ">@author</span><span style="color: #808080; font-style: italic; "> Felix Palmen
//
</span><span style="color: #800000; font-weight: bold; ">simple</span><span style="color: #000000; "> </span><span style="color: #000000; ">PastryRoutingTable</span><span style="color: #000000; ">
{
    </span><span style="color: #800000; font-weight: bold; ">parameters</span><span style="color: #000000; ">:
        </span><span style="color: #000000; font-weight: bold; ">@display</span><span style="color: #000000; ">(</span><span style="color: #008000; ">&quot;i=block/table&quot;</span><span style="color: #000000; ">);
}

</span><span style="color: #808080; font-style: italic; ">//
// This module contains the leaf set of the Pastry implementation.
//
// </span><span style="color: #000080; ">@author</span><span style="color: #808080; font-style: italic; "> Felix Palmen
//
</span><span style="color: #800000; font-weight: bold; ">simple</span><span style="color: #000000; "> </span><span style="color: #000000; ">PastryLeafSet</span><span style="color: #000000; ">
{
    </span><span style="color: #800000; font-weight: bold; ">parameters</span><span style="color: #000000; ">:
        </span><span style="color: #000000; font-weight: bold; ">@display</span><span style="color: #000000; ">(</span><span style="color: #008000; ">&quot;i=block/table&quot;</span><span style="color: #000000; ">);
}

</span><span style="color: #808080; font-style: italic; ">//
// This module contains the neighborhood set of the Pastry implementation.
//
// </span><span style="color: #000080; ">@author</span><span style="color: #808080; font-style: italic; "> Felix Palmen
//
</span><span style="color: #800000; font-weight: bold; ">simple</span><span style="color: #000000; "> </span><span style="color: #000000; ">PastryNeighborhoodSet</span><span style="color: #000000; ">
{
    </span><span style="color: #800000; font-weight: bold; ">parameters</span><span style="color: #000000; ">:
        </span><span style="color: #000000; font-weight: bold; ">@display</span><span style="color: #000000; ">(</span><span style="color: #008000; ">&quot;i=block/table&quot;</span><span style="color: #000000; ">);
}

</span><span style="color: #808080; font-style: italic; ">//
// Implementation of the Pastry KBR overlay as described in
// &quot;Pastry: Scalable, Decentralized Object Location, and 
// Routing for Large-Scale Peer-to-Peer Systems&quot; 
// by Antony Rowstron and Peter Druschel, published in 
// Lecture Notes in Computer Science, volume 2218.
//
// </span><span style="color: #000080; ">@author</span><span style="color: #808080; font-style: italic; "> Felix Palmen
//
</span><span style="color: #800000; font-weight: bold; ">module</span><span style="color: #000000; "> </span><span style="color: #000000; ">PastryModules</span><span style="color: #000000; "> </span><span style="color: #800000; font-weight: bold; ">like</span><span style="color: #000000; "> </span><span style="color: #000000; ">IOverlay</span><span style="color: #000000; ">
{
    </span><span style="color: #800000; font-weight: bold; ">gates</span><span style="color: #000000; ">:
        </span><span style="color: #000080; font-weight: bold; ">input</span><span style="color: #000000; "> </span><span style="color: #000000; ">udpIn</span><span style="color: #000000; ">;   </span><span style="color: #808080; font-style: italic; ">// gate from the UDP layer
</span><span style="color: #000000; ">        </span><span style="color: #000080; font-weight: bold; ">output</span><span style="color: #000000; "> </span><span style="color: #000000; ">udpOut</span><span style="color: #000000; ">;    </span><span style="color: #808080; font-style: italic; ">// gate to the UDP layer
</span><span style="color: #000000; ">        </span><span style="color: #000080; font-weight: bold; ">input</span><span style="color: #000000; "> </span><span style="color: #000000; ">tcpIn</span><span style="color: #000000; ">;    </span><span style="color: #808080; font-style: italic; ">// gate from the TCP layer
</span><span style="color: #000000; ">        </span><span style="color: #000080; font-weight: bold; ">output</span><span style="color: #000000; "> </span><span style="color: #000000; ">tcpOut</span><span style="color: #000000; ">;    </span><span style="color: #808080; font-style: italic; ">// gate to the TCP layer
</span><span style="color: #000000; ">        </span><span style="color: #000080; font-weight: bold; ">input</span><span style="color: #000000; "> </span><span style="color: #000000; ">appIn</span><span style="color: #000000; ">;   </span><span style="color: #808080; font-style: italic; ">// gate from the application
</span><span style="color: #000000; ">        </span><span style="color: #000080; font-weight: bold; ">output</span><span style="color: #000000; "> </span><span style="color: #000000; ">appOut</span><span style="color: #000000; ">;    </span><span style="color: #808080; font-style: italic; ">// gate to the application
</span><span style="color: #000000; ">
    </span><span style="color: #800000; font-weight: bold; ">submodules</span><span style="color: #000000; ">:
        </span><span style="color: #000000; ">pastry</span><span style="color: #000000; ">: </span><span style="color: #000000; ">Pastry</span><span style="color: #000000; "> {
            </span><span style="color: #800000; font-weight: bold; ">parameters</span><span style="color: #000000; ">:
                </span><span style="color: #000000; font-weight: bold; ">@display</span><span style="color: #000000; ">(</span><span style="color: #008000; ">&quot;p=60,52;i=block/circle&quot;</span><span style="color: #000000; ">);
        }
        </span><span style="color: #000000; ">pastryRoutingTable</span><span style="color: #000000; ">: </span><span style="color: #000000; ">PastryRoutingTable</span><span style="color: #000000; "> {
            </span><span style="color: #800000; font-weight: bold; ">parameters</span><span style="color: #000000; ">:
                </span><span style="color: #000000; font-weight: bold; ">@display</span><span style="color: #000000; ">(</span><span style="color: #008000; ">&quot;p=140,68;i=block/table&quot;</span><span style="color: #000000; ">);
        }
        </span><span style="color: #000000; ">pastryLeafSet</span><span style="color: #000000; ">: </span><span style="color: #000000; ">PastryLeafSet</span><span style="color: #000000; "> {
            </span><span style="color: #800000; font-weight: bold; ">parameters</span><span style="color: #000000; ">:
                </span><span style="color: #000000; font-weight: bold; ">@display</span><span style="color: #000000; ">(</span><span style="color: #008000; ">&quot;p=220,52;i=block/table&quot;</span><span style="color: #000000; ">);
        }
        </span><span style="color: #000000; ">pastryNeighborhoodSet</span><span style="color: #000000; ">: </span><span style="color: #000000; ">PastryNeighborhoodSet</span><span style="color: #000000; "> {
            </span><span style="color: #800000; font-weight: bold; ">parameters</span><span style="color: #000000; ">:
                </span><span style="color: #000000; font-weight: bold; ">@display</span><span style="color: #000000; ">(</span><span style="color: #008000; ">&quot;p=300,68;i=block/table&quot;</span><span style="color: #000000; ">);

        }
    </span><span style="color: #800000; font-weight: bold; ">connections</span><span style="color: #000000; "> </span><span style="color: #800000; font-weight: bold; ">allowunconnected</span><span style="color: #000000; ">:
        </span><span style="color: #000000; ">udpIn</span><span style="color: #000000; "> </span><span style="color: #800000; font-weight: bold; ">--&gt;</span><span style="color: #000000; "> </span><span style="color: #000000; ">pastry</span><span style="color: #000000; ">.</span><span style="color: #000000; ">udpIn</span><span style="color: #000000; ">;
        </span><span style="color: #000000; ">udpOut</span><span style="color: #000000; "> </span><span style="color: #800000; font-weight: bold; ">&lt;--</span><span style="color: #000000; "> </span><span style="color: #000000; ">pastry</span><span style="color: #000000; ">.</span><span style="color: #000000; ">udpOut</span><span style="color: #000000; ">;
        </span><span style="color: #000000; ">appIn</span><span style="color: #000000; "> </span><span style="color: #800000; font-weight: bold; ">--&gt;</span><span style="color: #000000; "> </span><span style="color: #000000; ">pastry</span><span style="color: #000000; ">.</span><span style="color: #000000; ">appIn</span><span style="color: #000000; ">;
        </span><span style="color: #000000; ">appOut</span><span style="color: #000000; "> </span><span style="color: #800000; font-weight: bold; ">&lt;--</span><span style="color: #000000; "> </span><span style="color: #000000; ">pastry</span><span style="color: #000000; ">.</span><span style="color: #000000; ">appOut</span><span style="color: #000000; ">;

}
</span></pre>
   <hr><p class="footer"><a href="http://creativecommons.org/licenses/by-sa/3.0" target="_top"><img src="by-sa.png"></a> This documentation is released under the <a href="http://creativecommons.org/licenses/by-sa/3.0" target="_top">Creative Commons license</a></p>
   </body>
</html>
